<?php
namespace app\api\middleware;
use app\common\model\UserModel;

class ManageCheck{
    public function handle($request, \Closure $next)
    {
        $open_id = $request->param('open_id/s','');
        if($open_id){
            if(null === $user_info = UserModel::where('open_id',$open_id)->find()){
                $user_info = new UserModel();
                $user_info->firm_id = $staff_info->firm_id;
                $user_info->open_id = $open_id;
                $user_info->save();
            }
            $request->user_info = $user_info;//用户详细信息
        }else{
            return error('非法访问#101'.$open_id);
        }
        return $next($request);
    }
}